package com.haojin.spring.resources;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.core.io.Resource;

/**
 * @author .29.
 * @create 2023-03-02 20:53
 */
public class ResourceLoaderDemo {
    public static void main(String[] args){
        //示例一：
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
        Resource resource = context.getResource("baidu.txt");
        System.out.println(resource.getFilename());
        System.out.println(resource.getDescription());

        System.out.println("----------------------------------------------------------");

        //示例二：
        FileSystemXmlApplicationContext context2 = new FileSystemXmlApplicationContext();
        Resource resource2 = context.getResource("baidu.txt");
        System.out.println(resource2.getFilename());
        System.out.println(resource2.getDescription());
    }
}
